package com.mall.mymall.dao.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;


import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;

/**
 * <p>
 *
 * </p>
 *
 * @author 十里坡
 * @since 2025-03-06
 */
@Data
@Document(indexName = "products") //关联elasticsearch索引
public class Products implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    @TableId(value = "product_id", type = IdType.AUTO)
    @Id
    @Field(name = "product_id", type = FieldType.Keyword)
    private Integer productId;

    @Field(name = "product_name", type = FieldType.Text, analyzer = "ik_max_word")
    private String productName;

    @Field(type = FieldType.Scaled_Float, scalingFactor = 100)
    private String price;

    private Integer stock;

    @Field(type = FieldType.Text, analyzer = "ik_max_word")
    private String description;

    @JsonFormat(pattern = "yyyy-MM-dd")
    @Field(name = "created_time", type = FieldType.Date)
    private LocalDate createdTime;

    private Integer storeId;

    private Integer organizationId;

    @Field(name="product_image",type = FieldType.Text)
    private String productImage;

    private Integer categoryId;


}
